<html>

<head></head>

<body>
    <div id="app">
    </div>

    <div id="test">
    </div>

    <script src="https://unpkg.com/vue"></script>
    <script>
        // 工厂
        var buildTemplate = function (name) {
            var template = ''
            if ('app' === name) {
                template = '<p style="color:red;">Hello ' + name + '</p>'
            } else if ('test' === name) {
                template = '<p style="color:blue;">Hello ' + name + '</p>'
            }
            return template
        }
        const appName = 'app'
        // 工厂
        var app = new Vue({
            el: '#'+ appName,
            template: buildTemplate(appName)
        })

    </script>
</body>

</html>